﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class AssetCls
    {
        public string AssetName;
        public string AssetCode;
        public string SmsUrl;
        public string DataUrl;
    }

    public class AssetParser
    {
        public static AssetCls CreateInstance()
        {
            //tao 1 class trang....
            AssetCls oAssetCls = new AssetCls();
            return oAssetCls;
        }

        public static AssetCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            AssetCls oAssetCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oAssetCls;
        }


        public static AssetCls ParseFromDataRow(DataRow dr)
        {
            AssetCls OAssetCls = new AssetCls();
            OAssetCls.AssetCode = (string)dr["AssetCode"];
            OAssetCls.AssetName = (string)dr["AssetName"];
            OAssetCls.SmsUrl = (string)dr["SMSUrl"];
            OAssetCls.DataUrl = (string)dr["DataUrl"];

            return OAssetCls;
        }

        public static AssetCls[] ParseFromDataTable(DataTable dtTable)
        {
            AssetCls[] Assets = new AssetCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                Assets[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return Assets;
        }
    }
}


